<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 正整数数组
        const nums = [1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 91, 97, 100];

        function isPrime (num) {
            switch (num) {
                case 1:
                    return false;
                case 2:
                    return true;
            
                default:
                    for (let n = 2; n < num; n++) {
                        if (num % n === 0) {
                            return false;
                        }
                    }
                    return true;
            }
        }

        function getPrimes (arr) {
            return arr.filter(isPrime);
        }

        console.log(getPrimes(nums)); // [2, 3, 5, 7, 11, 13, 17, 97]

    </script>
</body>
</html>